#include <bits/stdc++.h>
using namespace std;

int ans = 0;
bool ok = true;

string t;
vector<string> str;
vector<pair<int, int>> match;

int n;

/**
 * 寻找匹配子串，将答案存在 match 中
 * @param L 下一个匹配子串的左端点
 * @param R 下一个匹配子串的右端点
 */
void Find(int L, int R) {
  int Max = 0, id = -1, pos = -1;
  for (int i = L; i <= R; ++i) {
    for (int j = 0; j < str.size(); ++j) {
      const string &s = str[j];
      if (i + s.size() > t.size() || i + s.size() <= R) continue;
      if (t.substr(i, s.size()) == s) {
        if (i + s.size() > Max) {  // 每次找**最长覆盖**
          Max = i + s.size();
          id = j;
          pos = i;
        }
      }
    }
  }
  if (id == -1) {
    ok = false;
    return;
  } else {
    match.emplace_back(id, pos);  // 答案：把第 id 个字符串放在 pos 上
    ans++;
    if (Max == t.size())
      return;
    else
      Find(max(pos + 1, R + 1), Max);
  }
}

void solve() {
  ans = 0;
  ok = true;

  cin >> t >> n;
  str.clear();
  match.clear();
  str.resize(n);

  for (int i = 0; i < n; ++i) cin >> str[i];

  Find(0, 0);
  if (!ok)
    cout << "-1\n";
  else {
    cout << ans << endl;
    for (auto &p : match) cout << p.first + 1 << ' ' << p.second + 1 << endl;
  }
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
